/* d3des.h -
 *
 * Headers and defines for d3des.c
 * Graven Imagery, 1992.
 *
 * Copyright (c) 1988,1989,1990,1991,1992 by Richard Outerbridge
 * (GEnie : OUTER; CIS : [71755,204])
 */

#ifdef __STDC__
# define        P(s) s
#else
# define P(s) ()
#endif

/* A useful alias on 68000-ish machines, but NOT USED HERE. */

typedef union {
   unsigned long blok[2];
   unsigned short word[4];
   unsigned char byte[8];
   } M68K;

void deskey P((BYTE *, int));

class DES {
public:
	enum DESOperation {Encryption, Decryption};
	enum DESModes {ECB, CBC};
	void Pad(BYTE *Input, ULONG &len);
	void Unpad(BYTE *Input, ULONG &len);
	void Init(BYTE *keyin, DESModes modeOfOperation);
	void Encrypt(BYTE *input, ULONG len);
	void Decrypt(BYTE *input, ULONG len);
private:
	void usekey(UINT32 *);
	void cpkey(UINT32 *);
	void des(BYTE *, BYTE *);
	void scrunch(BYTE *outof, UINT32 *into);
	void desfunc(UINT32 *block, UINT32 *keys);
	void unscrun(register UINT32 *outof, register BYTE *into);
	void cookey(register UINT32 *raw1);
	void deskey(BYTE *key, DESOperation edf);

};

